/**
 * Created by Administrator on 2015/11/24.
 */


module.exports = function (app) {

    app.get("/recipe/details/:id", function *() {
        var $self = this
        var id = $self.params.id
        if(!id){
            $self.status = 404
            return
        }
        var recipe = (yield $self.db('SELECT * FROM Recipe WHERE id=?', id))[0]
        console.log('---------------------------------')
        console.log(recipe.ingredient)
        recipe.ingredient = JSON.parse(recipe.ingredient)
        recipe.step = JSON.parse(recipe.step)
        yield $self.render('recipe/details', {
            title: recipe.title,
            recipe: recipe
        })
    })


}